// 实例状态
export const instanceStatusEnum = [
  {
    label: '创建中',
    value: 'creating'
  },
  {
    label: '运行中',
    value: 'running'
  },
  {
    label: '已关机',
    value: 'stopd',
    type: 'warning'
  }
]

// 操作状态
export const actionStatusEnum = [
  {
    label: '创建',
    value: 'create'
  },
  {
    label: '重置',
    value: 'setting'
  },
  {
    label: '启动',
    value: 'start'
  },
  {
    label: '重启',
    value: 'restart'
  },
  {
    label: '升降配',
    value: 'update'
  },
  {
    label: '重启',
    value: 'renew'
  },
  {
    label: '关机',
    value: 'stop',
    type: 'warning'
  },
  {
    label: '重置',
    value: 'reset'
  },
  {
    label: '重置密码',
    value: 'passwd'
  },
  {
    label: '重置端口号',
    value: 'reset_port'
  },
  {
    label: '重置端口',
    value: 'reset_custom_port'
  },
  {
    label: '备份镜像',
    value: 'image_create'
  },
  {
    label: '删除自定义镜像',
    value: 'image_delete',
    type: 'warning'
  },
  {
    label: '删除实例',
    value: 'delete',
    type: 'warning'
  },
  {
    label: '操作',
    value: 'set_tmp_disk_size',
  }
]

export const payType = {
  'card_less': '无卡启动',
  'free': '机主机器',
  'payg': '按量付费',
  'bidding': '竞价实例',
  'daily': '包天',
  'weekly': '包周',
  'monthly': '包月',
}

// 根据value回显label
export function selectDictLabel(datas, value) {
  if (value === undefined) {
    return "";
  }
  var actions = [];
  Object.keys(datas).some((key) => {
    if (datas[key].value == ('' + value)) {
      actions.push(datas[key].label);
      return true;
    }
  })
  if (actions.length === 0) {
    actions.push(value);
  }
  return actions.join('');
}


// 根据value回显颜色
export function selectDictColor(datas, value) {
  if (value === undefined) {
    return "";
  }
  var actions = [];
  Object.keys(datas).some((key) => {
    if (datas[key].value == ('' + value)) {
      actions.push(datas[key].type);
      return true;
    }
  })
  if (actions.length === 0) {
    actions.push(value);
  }
  return actions.join('');
}


// 操作日历记录状态
export const instanceLogEnum = [
  {
    label: '创建备份镜像',
    value: 'image_create',
  },
  {
    label: '变更计费',
    value: 'change_pay_type',
  },
  {
    label: '扩缩容',
    value: 'set_tmp_disk_size',
  },
  {
    label: '创建自定义端口',
    value: 'custom_port',
  },
  {
    label: '删除实例',
    value: 'release',
  },
  {
    label: '无卡启动',
    value: 'card_less_start',
  },
  {
    label: '重置密码',
    value: 'passwd',
  },
  {
    label: '重启',
    value: 'restart',
  },
  {
    label: '还原镜像',
    value: 'instance',
  },
  {
    label: '开机',
    value: 'start',
  },
  {
    label: '升降配',
    value: 'update',
  },
  {
    label: '定时关机',
    value: 'schedule_stop',
  },
  {
    label: '关机',
    value: 'stop',
  },
  {
    label: '到期转按量付费',
    value: 'change_pre_to_post'
  },
]